<?php
class Ad_priceModel extends Model {
	public function get_primary_key() {
		return $this->primary_key = 'id'; //设置主键
	}
	public function get_fields() {
		return $this->get_table_fields();
	}

	/**
	 * 获取金额
	 * @return mixed
	 */
	public function getPrice()
	{
		try {
			$query = $this->db->query('SELECT * FROM ca_ad_price where id=1');
			$row = $query->row();
		} catch (Exception $e) {
			log_message('error',  $e->getMessage());
		}
		return $row;
	}

	/**
	 * 更新金额
	 * @return mixed
	 */
	public function updatePrice($price)
	{
		try {
			$param=array(
				'price'=>$price,
			);
			$this->db->update('ca_ad_price', $param);
			$result = $this->db->affected_rows();
			if(empty($result)){
				return false;
			}
		} catch (Exception $e) {
			log_message('error',  $e->getMessage());
		}
		return true;
	}


}